import request from '@/utils/request'

export function getRoles() {
  return request({
    url: '/identity/roles/all',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/identity/roles',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/identity/roles/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: `/identity/roles/${id}`,
    method: 'delete'
  })
}

export async function getUserbyId(id){
  const res = await request.get(`/identity/Roles/getUsersById/${id}`);
  if (res.code == 1) {
    return res.data;
  } else {
    return Promise.reject(new Error(res.message));
  }
}
